package pub.dsb.example.sentinel;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

/**
 * 核心服务类
 */
@Service
public class TestService {

    @SentinelResource(value = "doTest", blockHandler = "blockHandler", fallback = "fallback") //声明限流的资源
    public String doTest(String name) {
        return "hello , " + name;
    }

    public String blockHandler(String name, BlockException e) { //降级，限流触发的
        return "被限流了";
    }

    public String fallback(String name) { //熔断触发的
        return "被降级了";
    }

}